package com.whpost.service.dao.stamp;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.whpost.service.entity.stamp.StampCard;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author YinZhuoyi
 * @since 2024-04-11
 */
public interface StampCardMapper extends BaseMapper<StampCard> {

    //查询卡片
    @Select("select * from stamp_card where id=#{0}")
    @Results(id="stamp_card_map",value = {
            @Result(column="hd_id",property="stampHd",
                    one=@One(
                            select="com.whpost.service.dao.stamp.StampHdMapper.getById")
            ),
            @Result(column="hd_id",property="hdId")
    })
    StampCard getById(Long id);

    //明细里面有没有
    @Select("select count(*) from stamp_card_order_mx where stamp_card_id=#{id}")
    int getsl(String id);

    //打删除标志
    @Update("update stamp_card set scbz='1' where id=#{id}")
    int updateScbz1(String id);

    //根据条件获取分页信息
    @Select("select * from stamp_card where ${ew.sqlSegment} ")
    @ResultMap(value="stamp_card_map")
    List<StampCard> getStampCardList(@Param("ew") QueryWrapper wrapper);

    @Select("select * from stamp_card where hd_id in (select id from stamp_hd where xm_id=#{xm_id})")
    @ResultMap(value="stamp_card_map")
    List<StampCard> getStampCardListByXm(@Param("xm_id") String xm_id);


}
